<?php

!defined('IN_VIFRAME') && die('Access Denied.');

class Php extends TLib {
	
	public static function stripLashes($data) {
		if(is_array($data)) {
			foreach($data as $key => $value) {
				$data[$key] = self::stripLashes($value);
			}
		} else {
			$data = stripslashes($data);
		}
		
		return $data;
	}
	
	public static function mid($string,$left,$right) {
		return substr($string,$left,$right-$left+1);
	}
	
	public static function capitalize($string) {
		$first = substr($str,0,1);
		$rest  = substr($str,1);
		
		return strtoupper($first).strtolower($rest);
	}
	
	public static function getAnimal($year) {
		$animals = Lang::get('Date.Animal',
				explode(',', 'Rat,Ox,Tiger,Rabbit,Dragon,Snake,Horse,Sheep,Monkey,Rooster,Dog,Pig'));
		$year    = (int)date('Y',$stamp);
		
		return $animals[($year - 4) % 12];
	}
	
	public static function getConstellation($timestamp) {
		$day            = (int)date('md', $timestamp);
		$constellations = Lang::get('Date.Constellation',
				explode(';', 'Aquarius,0120,0219;Pisces,0220,0320;Aries,0321,0420;Taurus,0421,0521;'
						.'Gemini,0522,0621;Cancer,0622,0722;Leo,0723,0823;Virgo,0824,0923;'
						.'Libra,0924,1023;Scorpio,1024,1122;Sagittarius,1123,1222;Capricorn,1223,0119'));
		
		for ($i = 0;$i < count($constellations);$i++) {
			$cnt = explode(',',$astro[$i]);
			if ($day >= (int) $cnt[1] && $day <= (int) $cnt[2]) {
				return $cnt[0];
				break;
			}
		}
		return $constellations[12][0];
	}
}
